package com.djx.redis.service;


import org.springframework.web.bind.annotation.PostMapping;

/**
 * @author dingjunxiong
 */
public interface RedisClientService {
    /**
     * 保存字符串
     * @param key
     * @param value
     * @param seconds
     * @return
     */
    @PostMapping(value = "/redis/set")
    String set(String key, String value, int seconds);

    /**
     * 获取字符串
     * @param key
     * @return
     */
    @PostMapping(value = "/redis/get")
    String get(String key);

    /**
     * 获取对象
     * @param key
     * @return
     */
    @PostMapping(value = "/redis/getObject")
    Object getObject(String key);

    /**
     * 保存对象
     * @param key
     * @param object
     * @param seconds
     * @return
     */
    @PostMapping(value = "/redis/setObject")
    String setObject(String key, Object object, int seconds);

    /**
     * 判断是否存在
     * @param key
     * @return
     */
    @PostMapping(value = "/redis/exists")
    Boolean exists(String key);

    /**
     * 设置过期时间
     * @param key
     * @param seconds
     * @return
     */
    @PostMapping(value = "/redis/expire")
    Boolean expire(String key, int seconds);

    /**
     * 删除
     * @param key
     * @return
     */
    @PostMapping(value = "/redis/del")
    Boolean del(String key);

    /**
     * 剩余生存时间
     * @param key
     * @return
     */
    @PostMapping(value = "/redis/ttl")
    Long ttl(String key);
}
